#ifndef ALGORITHM_H
#define ALGORITHM_H

//==============================================================================
//
//                 Algorithm - the gpx algorithm module
//
//               Copyright (C) 2018  Dick van Oudheusden
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free
// Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
//==============================================================================

#include <string>

namespace gpx
{
  ///
  /// @module Algorithm
  ///
  /// @brief The gpx algorithm module.
  ///

  ///
  /// Convert degrees to radians
  ///
  /// @param deg       the degrees
  ///
  /// @return the radians
  ///
  double deg2rad(double deg);

  ///
  /// Convert radians to degrees
  ///
  /// @param rad      the radians
  ///
  /// @return the degrees
  ///
  double rad2deg(double rad);

  ///
  /// Calculate the distance between two lat,long coordinates
  ///
  /// @param lat1deg      the latitude of the first coordinate
  /// @param lon1deg      the longitude of the first coordinate
  /// @param lat2deg      the latitude of the second coordinate
  /// @param lon2deg      the longitude of the second coordinate
  ///
  /// @return the distance in metres
  ///
  double calcDistance(double lat1deg, double lon1deg, double lat2deg, double lon2deg);

  ///
  /// Calculate the bearing between two lat,long coordinates
  ///
  /// @param lat1deg      the latitude of the first coordinate
  /// @param lon1deg      the longitude of the first coordinate
  /// @param lat2deg      the latitude of the second coordinate
  /// @param lon2deg      the longitude of the second coordinate
  ///
  /// @return the bearing in radians
  ///
  double calcBearing(double lat1deg, double lon1deg, double lat2deg, double lon2deg);

  ///
  /// Calculate the crosstrack distance from the third coordinate to the line of the first two coordinates
  ///
  /// @param lat1deg      the latitude of the first coordinate of the line
  /// @param lon1deg      the longitude of the first coordinate of the line
  /// @param lat2deg      the latitude of the second coordinate of the line
  /// @param lon2deg      the longitude of the second coordinate of the line
  /// @param lat3deg      the latitude of the third coordinate
  /// @param lon3deg      the longitude of the third coordinate
  ///
  /// @return the crosstrack distance in metres
  ///
  double calcCrosstrack(double lat1deg, double lon1deg, double lat2deg, double lon2deg, double lat3deg, double lon3deg);
}
#endif

